import request from '@/utils/request'
import qs from 'qs'

export function add(data) {
  return request({
    url: 'mall/yxStoreProduct/addOrSave',
    method: 'post',
    data
  })
}

export function del(id) {
  return request({
    url: 'mall/yxStoreProduct/' + id,
    method: 'delete'
  })
}

export function edit(data) {
  return request({
    url: 'mall/yxStoreProduct',
    method: 'put',
    data
  })
}

export function onsale(id, data) {
  return request({
    url: 'mall/yxStoreProduct/onsale/' + id,
    method: 'post',
    data
  })
}

export function recovery(id) {
  return request({
    url: 'mall/yxStoreProduct/recovery/' + id,
    method: 'delete'
  })
}

export function isFormatAttr(id, data) {
  return request({
    url: 'mall/yxStoreProduct/isFormatAttr/' + id,
    method: 'post',
    data
  })
}

export function isFormatAttrForActivity(id, data) {
  return request({
    url: 'mall/yxStoreProduct/isFormatAttrForActivity/' + id,
    method: 'post',
    data
  })
}
export function setAttr(id, data) {
  return request({
    url: 'mall/yxStoreProduct/setAttr/' + id,
    method: 'post',
    data
  })
}

export function clearAttr(id) {
  return request({
    url: 'mall/yxStoreProduct/clearAttr/' + id,
    method: 'post'
  })
}

export function getAttr(id) {
  return request({
    url: 'mall/yxStoreProduct/attr/' + id,
    method: 'get'
  })
}

export function getInfo(id) {
  return request({
    url: 'mall/yxStoreProduct/info/' + id,
    method: 'get'
  })
}
// 查门店信息
export function queryRetail(id) {
  return request({
    url: `retail/stock/queryRetail?id=${id}`,
    method: 'get',
    data: id
  })
}

export function queryGoods(data) {
  return request({
    url: 'retail/stock/queryGoods?' + qs.stringify(data, { indices: false }),
    method: 'get'
  })
}

// 条件查询
export function queryBYstore(data) {
  return request({
    url: 'retail/stock/queryBYstore?' + qs.stringify(data, { indices: false }),
    method: 'get'
  })
}
// 提交订单
export function sumitOrder(data) {
  return request({
    url: 'retail/order/sumitOrder',
    method: 'post',
    data
  })
}

export function queryByCebters(data) {
  return request({
    url: 'retail/stock/queryByCebters?' + qs.stringify(data, { indices: false }),
    method: 'get'

  })
}

export default { queryBYstore }
